package org.ruoyi.system.controller.system;

import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.satoken.utils.LoginHelper;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.system.domain.vo.SysUserVo;
import org.ruoyi.system.domain.vo.WxUserAuthVo;
import org.ruoyi.system.service.ISysUserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户信息
 *
 * @author Lion Li
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wx/user")
public class WxUserController extends BaseController {

    private final ISysUserService userService;


    /**
     * 小程序获取用户信息
     */
    @GetMapping("/getInfo")
    public R<WxUserAuthVo> auth() {
        SysUserVo sysUserVo = userService.selectUserById(LoginHelper.getUserId());
        return R.ok(BeanUtil.toBean(sysUserVo, WxUserAuthVo.class));
    }

}
